<?php

namespace app\controller;

use app\BaseController;
use think\facade\Db;

class Goods extends BaseController
{
    public function list()
    {
        $page = input('page', 0);
        $limit = input('limit', 20);
        $data = Db::name('goods')->order('id', 'desc')->paginate($limit);
        return $data ? $this->returnJson(200, $data) : $this->returnJson(404, [], '失败');
    }
    public function info($id)
    {
        $data = Db::name('goods')->find($id);
        $data['content'] = json_decode($data['content'],true);
        $data['attribute'] = json_decode($data['attribute'],true);
        $data['swiper'] = json_decode($data['swiper'],true);
        return $data ? $this->returnJson(200, $data) : $this->returnJson(404, [], '失败');
    }
}
